package com.itheima02;

import java.io.IOException;
import java.net.*;

public class SendUDPDemo {
    public static void main(String[] args) throws IOException {

        // 创建发送端 socket
        DatagramSocket ds = new DatagramSocket();

        // 创建发送包
        byte[] bytes = "hello.udp.123".getBytes();
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length, InetAddress.getByName("127.0.0.1"), 10086);

        // 发送数据
        ds.send(dp);

        // 关闭
        ds.close();

    }
}
